<template>
    <div class= 'messageRecord'>
        <div class = 'sectionBox' ref="sectionBox">
            <h2>
                <span>短信记录</span>
            </h2>
            <div class="box">
                <complex-table :hasSelection = false :list= 'list' :totalList='totalList1' :theadList='theadList' :operationButtons = 'operationButtons' @getListByPagination='getTableList1' @initListQuery = 'initListQuery'></complex-table>
            </div>
        </div>
    </div>
</template>
<script>
import complexTable from '@/views/table/complexTable'
import { pending } from '@/api/knowledgeManage/message'
export default {
  components: { complexTable },
  props: {
    patientId: {
      default: 0,
      type: Number
    }
  },
  data() {
    return {
      list: [],
      theadList: [
        {
          label: 'createTime',
          text: '发送时间'
        },
        {
          label: 'updateName',
          text: '发送人'
        },
        {
          label: 'typeShow',
          text: '短信类型'
        },
        {
          label: 'content',
          text: '短信内容'
        }
      ],
      filter: {
        patientId: 0,
        page: 1,
        limit: 10
      },
      totalList1: 0,
      operationButtons: []
    }
  },
  mounted() {
    const CH = document.body.offsetHeight
    this.$refs.sectionBox.style.height = CH - 165 + 'px'
  },
  created() {
    this.filter.patientId = this.patientId
    // this.getTableList1(this.filter)
  },
  methods: {
    initListQuery(listQuery) {
      this.filter.limit = listQuery.limit
      this.filter.page = listQuery.page
    },
    getTableList1(listQuery) {
      this.filter.page = listQuery.page
      this.filter.limit = listQuery.limit
      pending({
        patientId: listQuery.patientId,
        page: listQuery.page,
        limit: listQuery.limit
      }).then((res) => {
        this.list = res.data.list
        this.totalList1 = res.data.total
      })
    }
  },
  watch: {
    patientId: function() {
      this.filter.patientId = this.patientId
      this.getTableList1(this.filter)
    }
  }
}
</script>
<style lang="scss" scoped>
@import '../../styles/case.scss';
</style>



